﻿<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:workflow="clr-namespace:Rio.Framework.Pages.Workflow;assembly=Rio.Framework.Pages"
             xmlns:conv="clr-namespace:Rio.Framework.Pages.Helpers.Converter;assembly=Rio.Framework.Pages"
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
             xmlns:filterControls="clr-namespace:Rio.Framework.Pages.Workflow.Filters;assembly=Rio.Framework.Pages"
             xmlns:Rio_Framework_Pages_Controls="clr-namespace:Rio.Framework.Pages.Controls;assembly=Rio.Framework.Pages"
             xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
             xmlns:MenuOffice="clr-namespace:Rio.Framework.Pages.MenuOffice;assembly=Rio.Framework.Pages"
             xmlns:Models="clr-namespace:Rio.Framework.Pages.Workflow.Models;assembly=Rio.Framework.Pages"
                     xmlns:BaseClass="clr-namespace:Rio.Framework.Pages.Controls.BaseClass;assembly=Rio.Framework.Pages"
                     x:Name="userControl"
             x:Class="Rio.Application.RioWeb.Flow.Views.FlowView"
             mc:Ignorable="d"
             d:DesignHeight="768"
             d:DesignWidth="1024">

    <UserControl.Resources>
        <conv:IEnumerableToQueryableCollectionView x:Key="IEnumerableToQueryableCollectionView" />
        <conv:BoxMessageReadedToImageConverter x:Key="BoxMessageReadedToImageConverter" />

        <telerik:ContainerBindingCollection x:Key="ContainerBindings">
            <telerik:ContainerBinding PropertyName="IsExpanded"
                                      Binding="{Binding bIsExpanded}" />
            <telerik:ContainerBinding PropertyName="IsSelected"
                                      Binding="{Binding bIsSelected}" />
            <telerik:ContainerBinding PropertyName="IsDropAllowed"
                                      Binding="{Binding bIsDropAllowed}" />
            <telerik:ContainerBinding PropertyName="DefaultImageSrc"
                                      Binding="{Binding sImageSrc}" />
        </telerik:ContainerBindingCollection>

        <DataTemplate x:Key="EditTreeViewTemplate">
            <TextBox x:Uid="{Binding iIdRepertory}"
                     Text="{Binding sText, Mode=TwoWay}" />
        </DataTemplate>

        <telerik:HierarchicalDataTemplate x:Key="TreeViewItemTemplate"
                                          ItemsSource="{Binding Items}"
                                          telerik:ContainerBinding.ContainerBindings="{StaticResource ContainerBindings}">
            <TextBlock x:Uid="{Binding iIdRepertory}"
                       Text="{Binding sText}"
                       FontWeight="{Binding TextFont}" />

        </telerik:HierarchicalDataTemplate>

        <telerik:HierarchicalDataTemplate x:Key="AdminTreeViewItemTemplate"
                                          ItemsSource="{Binding Items}"
                                          telerik:ContainerBinding.ContainerBindings="{StaticResource ContainerBindings}">
            <TextBlock x:Uid="{Binding iIdRepertory}"
                       Text="{Binding sText}"
                       FontWeight="{Binding TextFont}" />

        </telerik:HierarchicalDataTemplate>

        <SolidColorBrush x:Key="ControlSubItem_OuterBorder_MouseOver"
                         Color="#FFFFC92B" />
        <Thickness x:Key="ControlSubItem_OuterBorderThickness">1</Thickness>
        <SolidColorBrush x:Key="ControlSubItem_InnerBorder_MouseOver"
                         Color="#FFFFFFFF" />
        <Thickness x:Key="ControlSubItem_InnerBorderThickness">1</Thickness>
        <LinearGradientBrush x:Key="ControlSubItem_Background_MouseOver"
                             EndPoint="0.5,1"
                             StartPoint="0.5,0">
            <GradientStop Color="#FFFFFBA3"
                          Offset="1" />
            <GradientStop Color="#FFFFFBDA"
                          Offset="0" />
        </LinearGradientBrush>
        <CornerRadius x:Key="ControlSubItem_InnerCornerRadius">0</CornerRadius>
        <CornerRadius x:Key="ControlSubItem_OuterCornerRadius">1</CornerRadius>
        <SolidColorBrush x:Key="ControlSubItem_OuterBorder_UnFocus"
                         Color="#FFdbdbdb" />
        <SolidColorBrush x:Key="ControlSubItem_InnerBorder_UnFocus"
                         Color="Transparent" />
        <LinearGradientBrush x:Key="ControlSubItem_Background_UnFocus"
                             EndPoint="0,1">
            <GradientStop Color="#FFf8f6f9"
                          Offset="0" />
            <GradientStop Color="#FF909090"
                          Offset="1" />
        </LinearGradientBrush>
        <SolidColorBrush x:Key="ControlSubItem_OuterBorder_Selected"
                         Color="#FFFFC92B" />
        <SolidColorBrush x:Key="ControlSubItem_InnerBorder_Selected"
                         Color="#FFFFFFFF" />
        <LinearGradientBrush x:Key="ControlSubItem_Background_Selected"
                             EndPoint="0.5,1"
                             StartPoint="0.5,0">
            <GradientStop Color="#FFFCE79F"
                          Offset="1" />
            <GradientStop Color="#FFFDD3A8" />
        </LinearGradientBrush>
        <SolidColorBrush x:Key="TreeView_LineColor"
                         Color="#FFCCCCCC" />
        <telerik:Office_BlackTheme x:Key="Theme2" />
        <SolidColorBrush x:Key="FocusBrushBlack"
                         Color="#FF000000" />
        <ControlTemplate x:Key="TreeViewItemDefaultTemplate"
                         TargetType="telerik:RadTreeViewItem">
            <Grid x:Name="RootElement">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <VisualStateManager.VisualStateGroups>
                    <VisualStateGroup x:Name="EditStates">
                        <VisualState x:Name="Display" />
                        <VisualState x:Name="Edit">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Duration="0"
                                                               Storyboard.TargetProperty="Visibility"
                                                               Storyboard.TargetName="EditHeaderElement">
                                    <DiscreteObjectKeyFrame KeyTime="0"
                                                            Value="Visible" />
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames Duration="0"
                                                               Storyboard.TargetProperty="Visibility"
                                                               Storyboard.TargetName="Header">
                                    <DiscreteObjectKeyFrame KeyTime="0"
                                                            Value="Collapsed" />
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                    </VisualStateGroup>
                    <VisualStateGroup x:Name="CommonStates">
                        <VisualState x:Name="Normal" />
                        <VisualState x:Name="Disabled">
                            <Storyboard>
                                <DoubleAnimation Duration="0:0:0.0"
                                                 To="0.35"
                                                 Storyboard.TargetProperty="Opacity"
                                                 Storyboard.TargetName="Header" />
                                <DoubleAnimation Duration="0:0:0.0"
                                                 To="0.35"
                                                 Storyboard.TargetProperty="Opacity"
                                                 Storyboard.TargetName="Image" />
                            </Storyboard>
                        </VisualState>
                        <VisualState x:Name="MouseOver">
                            <Storyboard>
                                <DoubleAnimation Duration="0:0:0.1"
                                                 To="1"
                                                 Storyboard.TargetProperty="Opacity"
                                                 Storyboard.TargetName="MouseOverVisual" />
                            </Storyboard>
                        </VisualState>
                    </VisualStateGroup>
                    <VisualStateGroup x:Name="SelectionStates">
                        <VisualState x:Name="Unselected" />
                        <VisualState x:Name="Selected">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Duration="0"
                                                               Storyboard.TargetProperty="Visibility"
                                                               Storyboard.TargetName="SelectionVisual">
                                    <DiscreteObjectKeyFrame KeyTime="0"
                                                            Value="Visible" />
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                        <VisualState x:Name="SelectedUnfocused">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Duration="0"
                                                               Storyboard.TargetProperty="Visibility"
                                                               Storyboard.TargetName="SelectionUnfocusedVisual">
                                    <DiscreteObjectKeyFrame KeyTime="0"
                                                            Value="Visible" />
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                    </VisualStateGroup>
                    <VisualStateGroup x:Name="LoadingOnDemandStates">
                        <VisualState x:Name="LoadingOnDemand">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Duration="0"
                                                               Storyboard.TargetProperty="Visibility"
                                                               Storyboard.TargetName="LoadingVisual">
                                    <DiscreteObjectKeyFrame KeyTime="0"
                                                            Value="Visible" />
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames Duration="0"
                                                               Storyboard.TargetProperty="Visibility"
                                                               Storyboard.TargetName="Expander">
                                    <DiscreteObjectKeyFrame KeyTime="0"
                                                            Value="Collapsed" />
                                </ObjectAnimationUsingKeyFrames>
                                <DoubleAnimation Duration="0:0:1"
                                                 From="0"
                                                 RepeatBehavior="Forever"
                                                 To="359"
                                                 Storyboard.TargetProperty="Angle"
                                                 Storyboard.TargetName="LoadingVisualAngleTransform" />
                            </Storyboard>
                        </VisualState>
                        <VisualState x:Name="LoadingOnDemandReverse" />
                    </VisualStateGroup>
                    <VisualStateGroup x:Name="FocusStates">
                        <VisualState x:Name="Focused">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Duration="0"
                                                               Storyboard.TargetProperty="Visibility"
                                                               Storyboard.TargetName="FocusVisual">
                                    <DiscreteObjectKeyFrame KeyTime="0"
                                                            Value="Visible" />
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                        <VisualState x:Name="Unfocused" />
                    </VisualStateGroup>
                    <VisualStateGroup x:Name="ExpandStates">
                        <VisualState x:Name="Expanded" />
                        <VisualState x:Name="Collapsed" />
                    </VisualStateGroup>
                </VisualStateManager.VisualStateGroups>
                <Grid x:Name="HeaderRow"
                      Background="Transparent"
                      MinHeight="{TemplateBinding MinHeight}">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Border BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Background="{TemplateBinding Background}"
                            Grid.ColumnSpan="6"
                            Grid.Column="2"
                            CornerRadius="2" />
                    <Border x:Name="MouseOverVisual"
                            BorderBrush="{StaticResource ControlSubItem_OuterBorder_MouseOver}"
                            BorderThickness="{StaticResource ControlSubItem_OuterBorderThickness}"
                            Grid.ColumnSpan="6"
                            Grid.Column="2"
                            CornerRadius="{StaticResource ControlSubItem_OuterCornerRadius}"
                            Opacity="0">
                        <Border BorderBrush="{StaticResource ControlSubItem_InnerBorder_MouseOver}"
                                BorderThickness="{StaticResource ControlSubItem_InnerBorderThickness}"
                                Background="{StaticResource ControlSubItem_Background_MouseOver}"
                                CornerRadius="{StaticResource ControlSubItem_InnerCornerRadius}" />
                    </Border>
                    <Border x:Name="SelectionUnfocusedVisual"
                            BorderBrush="{StaticResource ControlSubItem_OuterBorder_UnFocus}"
                            BorderThickness="{StaticResource ControlSubItem_OuterBorderThickness}"
                            Grid.ColumnSpan="6"
                            Grid.Column="2"
                            CornerRadius="{StaticResource ControlSubItem_OuterCornerRadius}"
                            Visibility="Collapsed">
                        <Border BorderBrush="{StaticResource ControlSubItem_InnerBorder_UnFocus}"
                                BorderThickness="{StaticResource ControlSubItem_InnerBorderThickness}"
                                Background="{StaticResource ControlSubItem_Background_UnFocus}"
                                CornerRadius="{StaticResource ControlSubItem_InnerCornerRadius}" />
                    </Border>
                    <Border x:Name="SelectionVisual"
                            BorderBrush="{StaticResource ControlSubItem_OuterBorder_Selected}"
                            BorderThickness="{StaticResource ControlSubItem_OuterBorderThickness}"
                            Grid.ColumnSpan="6"
                            Grid.Column="2"
                            CornerRadius="{StaticResource ControlSubItem_OuterCornerRadius}"
                            Visibility="Collapsed">
                        <Border BorderBrush="{StaticResource ControlSubItem_InnerBorder_Selected}"
                                BorderThickness="{StaticResource ControlSubItem_InnerBorderThickness}"
                                Background="{StaticResource ControlSubItem_Background_Selected}"
                                CornerRadius="{StaticResource ControlSubItem_InnerCornerRadius}" />
                    </Border>
                    <StackPanel x:Name="IndentContainer"
                                Orientation="Horizontal">
                        <Rectangle x:Name="IndentFirstVerticalLine"
                                   Stroke="{StaticResource TreeView_LineColor}"
                                   Visibility="Collapsed"
                                   VerticalAlignment="Top"
                                   Width="1">
                            <Rectangle.Clip>
                                <RectangleGeometry Rect="0,0,1,10000" />
                            </Rectangle.Clip>
                        </Rectangle>
                    </StackPanel>
                    <Grid x:Name="ListRootContainer"
                          Grid.Column="1"
                          HorizontalAlignment="Center"
                          MinWidth="20">
                        <Rectangle x:Name="HorizontalLine"
                                   HorizontalAlignment="Right"
                                   Height="1"
                                   Stroke="{StaticResource TreeView_LineColor}"
                                   VerticalAlignment="Center">
                            <Rectangle.Clip>
                                <RectangleGeometry Rect="0,0,10000,1" />
                            </Rectangle.Clip>
                        </Rectangle>
                        <Rectangle x:Name="VerticalLine"
                                   HorizontalAlignment="Center"
                                   Stroke="{StaticResource TreeView_LineColor}"
                                   VerticalAlignment="Top"
                                   Width="1">
                            <Rectangle.Clip>
                                <RectangleGeometry Rect="0,0,1,10000" />
                            </Rectangle.Clip>
                        </Rectangle>
                        <ToggleButton x:Name="Expander"
                                      Background="{TemplateBinding Background}"
                                      IsTabStop="False" />
                        <Grid x:Name="LoadingVisual"
                              HorizontalAlignment="Center"
                              RenderTransformOrigin="0.5,0.5"
                              Visibility="Collapsed"
                              VerticalAlignment="Center">
                            <Grid.RenderTransform>
                                <TransformGroup>
                                    <RotateTransform x:Name="LoadingVisualAngleTransform"
                                                     Angle="0"
                                                     CenterY="0.5"
                                                     CenterX="0.5" />
                                </TransformGroup>
                            </Grid.RenderTransform>
                            <Path Data="M1,0 A1,1,90,1,1,0,-1"
                                  Height="10"
                                  StrokeStartLineCap="Round"
                                  Stretch="Fill"
                                  Stroke="{TemplateBinding Foreground}"
                                  StrokeThickness="1"
                                  Width="10" />
                            <Path Data="M0,-1.1 L0.1,-1 L0,-0.9"
                                  Fill="{TemplateBinding Foreground}"
                                  HorizontalAlignment="Left"
                                  Height="4"
                                  Margin="5,-1.5,0,0"
                                  Stretch="Fill"
                                  StrokeThickness="1"
                                  VerticalAlignment="Top"
                                  Width="4" />
                        </Grid>
                    </Grid>
                    <CheckBox x:Name="CheckBoxElement"
                              Grid.Column="2"
                              IsTabStop="False"
                              Margin="5,0,0,0"
                              telerik:StyleManager.Theme="{StaticResource Theme2}"
                              Visibility="Collapsed"
                              VerticalAlignment="Center" />
                    <RadioButton x:Name="RadioButtonElement"
                                 Grid.Column="2"
                                 IsTabStop="False"
                                 Margin="5,0,0,0"
                                 telerik:StyleManager.Theme="{StaticResource Theme2}"
                                 Visibility="Collapsed"
                                 VerticalAlignment="Center" />
                    <Image x:Name="Image"
                           Grid.Column="3"
                           HorizontalAlignment="Center"
                           MaxWidth="16"
                           MaxHeight="16"
                           Margin="2"
                           Tag="Wow"
                           VerticalAlignment="Center" />
                    <Rectangle x:Name="FocusVisual"
                               Grid.ColumnSpan="6"
                               Grid.Column="2"
                               IsHitTestVisible="False"
                               RadiusY="3"
                               RadiusX="3"
                               Stroke="{StaticResource FocusBrushBlack}"
                               StrokeThickness="1"
                               StrokeDashArray="1 2"
                               Visibility="Collapsed" />
                    <Grid Grid.ColumnSpan="2"
                          Grid.Column="4">
                        <ContentPresenter x:Name="Header"
                                          ContentTemplate="{TemplateBinding HeaderTemplate}"
                                          Content="{TemplateBinding Header}"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          Margin="{TemplateBinding Padding}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                        <ContentPresenter x:Name="EditHeaderElement"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          Margin="{TemplateBinding Padding}"
                                          Visibility="Collapsed"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                    </Grid>
                </Grid>
                <ItemsPresenter x:Name="ItemsHost"
                                Grid.Row="1"
                                Visibility="Collapsed" />
            </Grid>
        </ControlTemplate>

        <Style x:Key="RadTreeViewItemStyle1"
               TargetType="telerik:RadTreeViewItem">
            <Setter Property="HorizontalContentAlignment"
                    Value="Left" />
            <Setter Property="VerticalContentAlignment"
                    Value="Center" />
            <Setter Property="CheckState"
                    Value="Off" />
            <Setter Property="BorderThickness"
                    Value="1" />
            <Setter Property="Padding"
                    Value="1 0 5 0" />
            <Setter Property="IsDropAllowed"
                    Value="True" />
            <Setter Property="ItemsOptionListType"
                    Value="Default" />
            <Setter Property="IsEnabled"
                    Value="True" />
            <Setter Property="MinHeight"
                    Value="24" />
            <Setter Property="Template"
                    Value="{StaticResource TreeViewItemDefaultTemplate}" />
            <Setter Property="ItemsPanel">
                <Setter.Value>
                    <ItemsPanelTemplate>
                        <telerik:TreeViewPanel VerticalAlignment="Bottom" />
                    </ItemsPanelTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Models:GridViewSelector x:Key="styleSelector" />

        </UserControl.Resources>

    <Grid x:Name="LayoutRoot"
          Background="White">

        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="GridViewStatesGroup">
                <VisualState x:Name="ClassicState">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)"
                                                       Storyboard.TargetName="GridViewMessageToolBar">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Visible</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)"
                                                       Storyboard.TargetName="GridViewMessages">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Visible</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)"
                                                       Storyboard.TargetName="DataPagerBox">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Visible</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)"
                                                       Storyboard.TargetName="WorkflowInstanceList">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="WorkflowState">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)"
                                                       Storyboard.TargetName="GridViewMessageToolBar">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)"
                                                       Storyboard.TargetName="GridViewMessages">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)"
                                                       Storyboard.TargetName="WorkflowInstanceList">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Visible</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)"
                                                       Storyboard.TargetName="DataPagerBox">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <MenuOffice:HeadMenu Name="headMenu" />

        <telerik:RadTabControl Grid.Row="1"
                               x:Name="tabControl"
                               Margin="1"
                               SelectionChanged="TabControlSelectionChanged"
                               IsContentPreserved="True"
                               BackgroundVisibility="Collapsed"
                               BorderBrush="{x:Null}"
                               Background="{x:Null}">
            <telerik:RadTabItem x:Name="MainTabHeader"
                                MinWidth="140"
                                FontWeight="Bold"
                                MinHeight="20">
                <Grid x:Name="TabLayoutRoot">
                    <Grid.Resources>
                        <Models:GridViewSelector x:Key="styleSelector" />
                    </Grid.Resources>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="300"
                                          MinWidth="30"
                                          MaxWidth="600" />
                        <ColumnDefinition Width="7" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition />
                    </Grid.RowDefinitions>


                    <ScrollViewer HorizontalScrollBarVisibility="Auto"
                                  VerticalScrollBarVisibility="Auto"
                                  BorderThickness="0">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition />
                            </Grid.RowDefinitions>

                            <!--Folder Message flow Panel-->
                            <telerik:RadPanelBar ExpandMode="Single"
                                                 HorizontalAlignment="Stretch"
                                                 VerticalAlignment="Stretch">
                                <telerik:RadPanelBarItem x:Name="radPanelBarItem"
                                                         IsExpanded="true"
                                                         VerticalAlignment="Center">
                                    <telerik:RadPanelBarItem.Header>
                                        <Grid Margin="3,3,0,3">
                                            <StackPanel Orientation="Horizontal">
                                                <Image Source="/Rio.Framework.Pages;component/Assets/Images/Folder.png"
                                                       Width="16"
                                                       Height="16" />
                                                <TextBlock x:Name="HeaderTextBlock"
                                                           Text="Dossier"
                                                           Margin="5,0,0,0"
                                                           VerticalAlignment="Center" />
                                            </StackPanel>
                                        </Grid>
                                    </telerik:RadPanelBarItem.Header>
                                    <telerik:RadTreeView x:Name="RadTreeViewBox"
                                                         ItemTemplate="{StaticResource TreeViewItemTemplate}"
                                                         ItemEditTemplate="{StaticResource EditTreeViewTemplate}"
                                                         ItemContainerStyle="{StaticResource RadTreeViewItemStyle1}"
                                                         IsExpandOnSingleClickEnabled="True"
                                                         IsLineEnabled="True"
                                                         IsEditable="False"
                                                         telerik:RadDragAndDropManager.AllowDrop="False"
                                                         IsDragDropEnabled="False"
                                                         ItemsSource="{Binding ItemsTreeView}"
                                                         SelectionChanged="RadTreeViewBox_SelectionChanged"
                                                         Margin="5,5,5,0"
                                                         VerticalAlignment="Center" />
                                </telerik:RadPanelBarItem>
                            </telerik:RadPanelBar>
                            <!--FolderType flow Panel-->
                            <workflow:FlowItemsPanel x:Name="FlowItemsPanel"
                                                     Grid.Row="1"
                                                     VerticalAlignment="Stretch"
                                                     FlowStructure="{Binding FlowStructureItems, ElementName=userControl, Mode=TwoWay}"
                                                     SelectedDataItemTreeView="{Binding SelectedDataItemTreeView, ElementName=userControl, Mode=TwoWay}" />
                        </Grid>
                    </ScrollViewer>

                    <sdk:GridSplitter Grid.Column="1"
                                      Width="8"
                                      HorizontalAlignment="Stretch"
                                      VerticalAlignment="Stretch"
                                      ShowsPreview="True"
                                      BorderBrush="#FF0E0E0E">
                        <sdk:GridSplitter.Background>
                            <RadialGradientBrush>
                                <GradientStop Color="White" />
                                <GradientStop Color="Gainsboro"
                                              Offset="0.43" />
                                <GradientStop Color="#FFADADAD"
                                              Offset="0.44" />
                                <GradientStop Color="#FFD4D4D4"
                                              Offset="1" />
                            </RadialGradientBrush>
                        </sdk:GridSplitter.Background>
                    </sdk:GridSplitter>

                    <Grid Grid.Column="2"
                          x:Name="GridRightPanel"
                          Margin="0">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>

                        <telerik:RadToolBar Height="35"
                                            x:Name="GridViewMessageToolBar">
                            <telerik:RadMenuItem x:Name="buttonDisplay"
                                                 IsEnabled="False"
                                                 Click="buttonDisplay_Click">
                                <telerik:RadMenuItem.Header>
                                    <StackPanel Orientation="Horizontal">
                                        <Image Source="/Rio.Framework.Pages;component/Assets/Images/display_flow.png"
                                               Margin="0,0,5,0" />
                                        <TextBlock x:Name="buttonDisplayHeader"
                                                   Text="Afficher"
                                                   VerticalAlignment="Center" />
                                    </StackPanel>
                                </telerik:RadMenuItem.Header>
                            </telerik:RadMenuItem>
                            <telerik:RadMenuItem x:Name="buttonDelete"
                                                 Click="buttonDelete_Click"
                                                 IsEnabled="False">
                                <telerik:RadMenuItem.Header>
                                    <StackPanel Orientation="Horizontal">
                                        <Image Source="/Rio.Framework.Pages;component/Assets/Images/delete_flow.png"
                                               Margin="0,0,5,0" />
                                        <TextBlock x:Name="buttonDeleteHeader"
                                                   Text="Supprimer"
                                                   VerticalAlignment="Center" />
                                    </StackPanel>
                                </telerik:RadMenuItem.Header>
                            </telerik:RadMenuItem>
                            <telerik:RadMenuItem x:Name="buttonRefresh"
                                                 Click="buttonRefresh_Click">
                                <telerik:RadMenuItem.Header>
                                    <StackPanel Orientation="Horizontal">
                                        <Image Source="/Rio.Framework.Pages;component/Assets/Images/Refresh.png"
                                               Margin="0,0,5,0" />
                                        <TextBlock x:Name="buttonRefreshHeader"
                                                   Text="Rafraichir"
                                                   VerticalAlignment="Center" />
                                    </StackPanel>
                                </telerik:RadMenuItem.Header>
                            </telerik:RadMenuItem>
                        </telerik:RadToolBar>

                        <!--GridViewMessages-->
                        <telerik:RadGridView x:Name="GridViewMessages"
                                             SelectionChanged="GridViewMessages_SelectionChanged"
                                             VerticalAlignment="Stretch"
                                             HorizontalAlignment="Stretch"
                                             Grid.Column="0"
                                             Grid.Row="1"
                                             SelectionMode="Extended"
                                             AutoGenerateColumns="False"
                                             CanUserDeleteRows="True"
                                             telerik:RadDragAndDropManager.AllowDrag="False"
                                             IsFilteringAllowed="True"
                                             ItemsSource="{Binding SelectedItemListMessage}"
                                             RowStyleSelector="{StaticResource styleSelector}"
                                             ShowGroupPanel="True"
                                             Deleting="GridViewMessages_Deleting">
                            <telerik:RadGridView.Columns>
                                <!--<telerik:GridViewDataColumn   x:Name="ColId"
                                                              Header="Id"
                                                              IsReadOnly="True"
                                                              IsVisible="False"
                                                              DataMemberBinding="{Binding iId}" />-->
                                <telerik:GridViewSelectColumn x:Name="ColSelection"
                                                              MinWidth="100"
                                                              MaxWidth="30">
                                    <telerik:GridViewSelectColumn.Header>
                                        <CheckBox x:Name="chkSelectAll"
                                                  IsChecked="False"
                                                  Checked="chkSelectAll_Checked"
                                                  Unchecked="chkSelectAll_Unchecked" />
                                    </telerik:GridViewSelectColumn.Header>
                                </telerik:GridViewSelectColumn>
                                <telerik:GridViewDataColumn x:Name="ColLu"
                                                            UniqueName="ColLu"
                                                            Header=""
                                                            IsReadOnly="True"
                                                            MinWidth="40"
                                                            MaxWidth="40"
                                                            DataMemberBinding="{Binding MyDocEtat}">
                                    <telerik:GridViewDataColumn.CellTemplate>
                                        <DataTemplate>
                                            <Image Source="{Binding MyDocEtat, Converter={StaticResource BoxMessageReadedToImageConverter}}"
                                                   HorizontalAlignment="Center"
                                                   VerticalAlignment="Center"
                                                   Width="20"
                                                   Height="20" />
                                        </DataTemplate>
                                    </telerik:GridViewDataColumn.CellTemplate>
                                    <telerik:GridViewDataColumn.FilteringControl>
                                        <filterControls:ReadOrNotControl x:Name="ReadFilterControl" />
                                    </telerik:GridViewDataColumn.FilteringControl>

                                </telerik:GridViewDataColumn>
                                <telerik:GridViewDataColumn x:Name="ColObjet"
                                                            UniqueName="ColObjet"
                                                            Header=""
                                                            IsReadOnly="True"
                                                            Width="150"
                                                            DataMemberBinding="{Binding Objet}" />
                                <telerik:GridViewDataColumn x:Name="ColExpediteur"
                                                            UniqueName="ColExpediteur"
                                                            Header=""
                                                            IsReadOnly="True"
                                                            Width="250"
                                                            DataMemberBinding="{Binding Emetteur.FullName}" />
                                <telerik:GridViewDataColumn x:Name="ColDestinataires"
                                                            UniqueName="ColDestinataires"
                                                            Header=""
                                                            IsReadOnly="True"
                                                            Width="350"
                                                            DataMemberBinding="{Binding DestinataireList}" />
                                <telerik:GridViewDataColumn x:Name="ColDate"
                                                            UniqueName="ColDate"
                                                            Header=""
                                                            IsReadOnly="True"
                                                            Width="200"
                                                            DataMemberBinding="{Binding Expedition}"
                                                            DataFormatString="{}{0:dd/MM/yyyy HH:mm:ss}" />
                            </telerik:RadGridView.Columns>

                            <telerik:RadContextMenu.ContextMenu>
                                <telerik:RadContextMenu x:Name="ContextMenu"
                                                        Opened="ContextMenuOpened">
                                    <telerik:RadMenuItem x:Name="DeleteContextMenu"
                                                         Click="ContextMenuClick">
                                        <telerik:RadMenuItem.Icon>
                                            <Image Source="/Rio.Framework.Pages;component/Assets/Images/Delete_folder.png"
                                                   Stretch="UniformToFill" />
                                        </telerik:RadMenuItem.Icon>
                                    </telerik:RadMenuItem>
                                    <telerik:RadMenuItem x:Name="DisplayMessageContextMenu"
                                                         Click="ContextMenuClick">
                                        <telerik:RadMenuItem.Icon>
                                            <Image Source="/Rio.Framework.Pages;component/Assets/Images/Lu.png"
                                                   Height="16"
                                                   Width="16"
                                                   Stretch="UniformToFill" />
                                        </telerik:RadMenuItem.Icon>
                                    </telerik:RadMenuItem>
                                </telerik:RadContextMenu>
                            </telerik:RadContextMenu.ContextMenu>
                        </telerik:RadGridView>

                        <!--WorkflowInstanceList-->
                        <workflow:WorkflowInstanceList x:Name="WorkflowInstanceList"
                                                       Visibility="Collapsed"
                                                       WorkflowInstanceDisplaying="OnWorkflowInstanceDisplaying"
                                                       WorkflowInstanceListDeleted="WorkflowInstanceList_WorkflowInstanceListDeleted"
                                                       WorkflowInstanceListRefreshed="WorkflowInstanceList_WorkflowInstanceListRefreshed"
                                                       Mode="Normal"
                                                       Grid.Column="0"
                                                       Grid.Row="1" />

                        <telerik:RadDataPager x:Name="DataPagerBox"
                                              Grid.Column="0"
                                              Grid.Row="2"
                                              DisplayMode="FirstLastPreviousNextNumeric"
                                              IsTotalItemCountFixed="False"
                                              PageSize="100"
                                              NumericButtonCount="10"
                                              Source="{Binding SelectedItemListMessage}" />
                    </Grid>
                </Grid>
            </telerik:RadTabItem>
            <telerik:RadTabItem x:Name="AdminTabHeader"
                                MinWidth="140"
                                Foreground="Red"
                                FontWeight="Bold"
                                DataContext="{Binding AdminDataViewModel}"
                                MinHeight="20">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="10" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>

                    <StackPanel Orientation="Vertical"
                                Grid.Row="0"
                                Grid.Column="0"
                                HorizontalAlignment="Stretch"
                                VerticalAlignment="Stretch">

                        <!--UCOrganizationTypePanel-->
                        <Rio_Framework_Pages_Controls:UCOrganizationTypePanel x:Name="OrganizationTypeControl"
                                                                              Height="140"
                                                                              Mode="Admin"
                                                                              OrganizationSelected="OrganizationTypeControl_OrganizationSelected"
                                                                              FolderSelected="OrganizationTypeControl_FolderSelected" />

                        <telerik:RadPanelBar x:Name="PanelBarAdminTree"
                                             ExpandMode="Single"
                                             VerticalAlignment="Stretch"
                                             HorizontalAlignment="Stretch">
                            <telerik:RadPanelBarItem x:Name="radAdminPanelBarItem"
                                                     IsExpanded="true"
                                                     Margin="0,0,1,0">
                                <telerik:RadPanelBarItem.Header>
                                    <Grid Margin="3,3,0,3">
                                        <StackPanel Orientation="Horizontal">
                                            <Image Source="/Rio.Framework.Pages;component/Assets/Images/Folder.png"
                                                   Width="16"
                                                   Height="16" />
                                            <TextBlock x:Name="AdminPanelBarHeaderTextBlock"
                                                       Text="Flux"
                                                       Margin="5,0,0,0"
                                                       VerticalAlignment="Center" />
                                        </StackPanel>
                                    </Grid>
                                </telerik:RadPanelBarItem.Header>
                                <!--Treeview-->
                                <telerik:RadTreeView x:Name="RadTreeViewAdminBox"
                                                     ItemTemplate="{StaticResource AdminTreeViewItemTemplate}"
                                                     IsExpandOnSingleClickEnabled="True"
                                                     IsLineEnabled="True"
                                                     IsEditable="False"
                                                     VerticalAlignment="Stretch"
                                                     HorizontalAlignment="Stretch"
                                                     telerik:RadDragAndDropManager.AllowDrop="False"
                                                     IsDragDropEnabled="False"
                                                     ItemsSource="{Binding ItemsTreeView}"
                                                     SelectionChanged="RadTreeViewAdminBox_SelectionChanged"
                                                     Margin="5,5,5,0"
                                                     IsEnabled="False" />
                            </telerik:RadPanelBarItem>
                        </telerik:RadPanelBar>
                    </StackPanel>

                    <!--GridSplitter-->
                    <sdk:GridSplitter Grid.Row="1"
                                      Grid.Column="1"
                                      x:Name="SplitBar"
                                      Width="8"
                                      HorizontalAlignment="Stretch"
                                      VerticalAlignment="Stretch"
                                      ShowsPreview="True"
                                      BorderBrush="#FF0E0E0E">
                        <sdk:GridSplitter.Background>
                            <RadialGradientBrush>
                                <GradientStop Color="White" />
                                <GradientStop Color="Gainsboro"
                                              Offset="0.43" />
                                <GradientStop Color="#FFADADAD"
                                              Offset="0.44" />
                                <GradientStop Color="#FFD4D4D4"
                                              Offset="1" />
                            </RadialGradientBrush>
                        </sdk:GridSplitter.Background>
                    </sdk:GridSplitter>

                    <!--WorkflowAdminInstanceList-->
                    <workflow:WorkflowInstanceTreeList x:Name="WorkflowAdminInstanceList"
                                                   Mode="Administration"
                                                   Grid.Row="1"
                                                   Grid.Column="2"
                                                   WorkflowInstanceListDeleted="WorkflowAdminInstanceList_WorkflowInstanceListDeleted"
                                                   WorkflowInstanceListRefreshed="WorkflowAdminInstanceList_WorkflowInstanceListRefreshed"
                                                   WorkflowInstanceDisplaying="OnWorkflowInstanceDisplaying"
                                                   Organization="{Binding SelectedOrganization, ElementName=OrganizationTypeControl, Mode=OneWay}"
                                                   FolderType="{Binding SelectedFolderType, ElementName=OrganizationTypeControl, Mode=OneWay}" />

                </Grid>

            </telerik:RadTabItem>
        </telerik:RadTabControl>

        <telerik:RadBusyIndicator Name="busyIndicator"
                                  IsBusy="true"
                                  Grid.ColumnSpan="2"
                                  Grid.RowSpan="2" />
    </Grid>
</UserControl>
